package verappdesktop.parsing;

import java.io.File;
import java.io.IOException;
import java.util.Scanner;
import java.util.TreeMap;

import verappdesktop.utils.VariableDataSet;

/**
 * Class for parsing cpj-files output by the Civinco-ECU.
 */
public class LogParser {
	private static final String EOF = "[end log_row_def]";

	public static VariableDataSet parseLog(File file) {
		if (file.canRead()){
			if (file.toString().split(".")[1].equals(".cpj")){
				Scanner sc = new Scanner(file);
				String line;
				String[] words;
				while (sc.hasNextLine()){
					line = sc.nextLine();
					if (line.equals(EOF)){
						break;
					}
					else {
						words = line.split("\t");
						TreeMap<Double,Double> data = new TreeMap<Double,Double>();
						VariableDataSet data = new VariableDataSet(new Variable(words[0]), values)
					}
				}
			}
			else {
				throw new IllegalArgumentException("File is not a cpj-file.");
			}
		}
		else {
			throw new IOException("Invalid filename.")
		}
	}

}
